/**
 * Created by zhu on 2016/2/3.
 */
$(function(){

    $.get(contextPath + "/order/my",function(data){
        initData(data);
    })
});

function initData(data){
    data = $.parseJSON(data);
    var tab1 = $('#tab1');
    var tab2 = $('#tab2');
    var tab3 = $('#tab3');
    var tab4 = $('#tab4');
    var tab5 = $('#tab5');

    tab1.empty();
    tab2.empty();
    tab3.empty();
    tab4.empty();
    tab5.empty();
    $.each(data.list,function(i,item){

        if(item.order_status==1){

            tab2.append(loadContent(item))
        }else if(item.order_status==2){
            tab3.append(loadContent(item))
        }else if(item.order_status==3){
            tab4.append(loadContent(item))
        }else if(item.order_status==4){
            tab5.append(loadContent(item))
        }

        tab1.append(loadContent(item))
    });

}
function loadContent(item){

    var  temp = '<div class="content-block">'+
        '<div class = "name_div">'+
        '<ul>'+
        ' <li class = "list_1"><span class="icon icon-browser"></span></li>'+
        ' <li class = "list_2">'+item.goods.users.shopName+'</li>'+
        ' <li class = "list_3">'+item.goods.category.name+'</li>'+
        ' <li class = "list_4"><span class="icon icon-right"></span></li>';
    if(item.order_status==1){
        temp+= ' <li class = "list_5">'+"待付款"+'&emsp;</li>'
    }else if(item.order_status==2){
        temp+= ' <li class = "list_5">'+"待发货"+'&emsp;</li>'
    }else if(item.order_status==3){
        temp+= ' <li class = "list_5">'+"待收货"+'&emsp;</li>'
    }else if(item.order_status==4){
        temp+= ' <li class = "list_5">'+"待评价"+'&emsp;</li>'
    }

    temp+= ' </ul>'+
        ' </div>'+

        '  <div class = "content_div">'+
        ' <div class = "goods_img"><img src="'+contextPath+item.goods.index_url+'"></div>'+
        ' <div class = "goods_intro">'+item.goods.name+'</div>'+
        ' <div class = "goods_price">￥'+item.goods.price+'&emsp;</div>'+
        '  </div>'+

        ' <div class = "money_div">共'+item.amount+'件商品&emsp;合计:￥'+item.price+'(含运费￥0.00)&emsp;</div>'+

        ' <div class = "line_div"></div>'+

        ' <div class = "more_div">'+
        ' <div class = "more">更多</div>'+
        ' <div class = "delete">'+
        ' <div>删除订单</div>'+
        ' </div>'+
        '<div class = "look">'+
        ' <div>查看物流</div>'+
        ' </div>'+
        ' <div class = "add">'+
        '  <div>追加评论</div>'+
        '  </div>'+
        ' </div>'+
        '</div>'+
        '<div class = "div_line"></div>';
    return temp;
}
